home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 7
/
FM Towns Free Software Collection 7.iso
/
taropyon
/
hewin
/
ccisrc
/
expcfg.cci
< prev
next >
Wrap
Text File
|
1993-11-30
|
8KB
|
251 lines
int _expSetup_maxibuf ( int maxibuf )
{
int ret, i;
char *dlg;
char buf[16];
dlg = DLG_getsOpen( DLGPOS_MOS_SET_HOME, DLGPOS_MOS_SET_HOME, 320,
"-maxibuf 1~64 (%d)", maxibuf );
DLG_getsSetTitle( dlg, "MAXIBUF" );
buf[0] = '\0';
ret = DLG_getsStart( dlg, 15, buf );
if ( ret > 0 )
{ i = atoi(buf);
if ( i > 0 && i <= 64 )
maxibuf = i;
}
DLG_getsClose(dlg);
return (maxibuf);
}
int _expSetup_nistack ( int nistack )
{
int ret, i;
char *dlg;
char buf[16];
dlg = DLG_getsOpen( DLGPOS_MOS_SET_HOME, DLGPOS_MOS_SET_HOME, 320,
"-nistack 1~16 (%d)", nistack );
DLG_getsSetTitle( dlg, "NISTACK" );
buf[0] = '\0';
ret = DLG_getsStart( dlg, 15, buf );
if ( ret > 0 )
{ i = atoi(buf);
if ( i > 0 && i <= 16 )
nistack = i;
}
DLG_getsClose(dlg);
return (nistack);
}
int _expSetup_istksize ( int istksize )
{
int ret, i;
char *dlg;
char buf[16];
dlg = DLG_getsOpen( DLGPOS_MOS_SET_HOME, DLGPOS_MOS_SET_HOME, 320,
"-istksize 1~8 (%d)", istksize );
DLG_getsSetTitle( dlg, "ISTKSIZE" );
buf[0] = '\0';
ret = DLG_getsStart( dlg, 15, buf );
if ( ret > 0 )
{ i = atoi(buf);
if ( i > 0 && i <= 8 )
istksize = i;
}
DLG_getsClose(dlg);
return (istksize);
}
int _expSetup_sub( char *obj, int maxibuf, int nistack, int istksize )
{
MNU_setObj(obj, 0, MNU_DIG, 'M', "-maxibuf %d" , maxibuf &0xFFFF, 1, NULL, NULL );
MNU_setObj(obj, 1, MNU_DIG, 'K', "-nistack %d" , nistack &0xFFFF, 2, NULL, NULL );
MNU_setObj(obj, 2, MNU_DIG, 'I', "-istksize %d" , istksize&0xFFFF, 3, NULL, NULL );
MNU_setObj(obj, 3, MNU_BLK, 0 , NULL , NULL , 0, NULL, NULL );
MNU_setObj(obj, 4, MNU_NOR, 'D', " Danger ちょっと危ない" , NULL , 4, NULL, NULL );
MNU_setObj(obj, 5, MNU_NOR, 'N', " Normal 僕は通信しない" , NULL , 5, NULL, NULL );
MNU_setObj(obj, 6, MNU_NOR, 'S', " Standard 標準設定" , NULL , 6, NULL, NULL );
MNU_setObj(obj, 7, MNU_NOR, 'B', " Bgm BGM はガンガン" , NULL , 7, NULL, NULL );
MNU_setObj(obj, 8, MNU_NOR, 'A', " Safety 安全設定" , NULL , 8, NULL, NULL );
MNU_setObj(obj, 9, MNU_BLK, 0 , NULL , NULL , 0, NULL, NULL );
MNU_setObj(obj,10, MNU_NOR, 'W', " Write 設定書込" , NULL , 9, NULL, NULL );
}
int CCI_expSetup(int argc, char **argv )
{
char *fp;
char fn[128], buf[32];
char *fdl;
char *dlg;
char *obj;
char *mnu;
int ret;
unsigned short chk_sum, sum;
unsigned short maxibuf, nistack, istksize;
unsigned short old_maxibuf, old_nistack, old_istksize;
unsigned int dx_ofs;
long ofs;
if ( (fdl = FDL_open(0)) == NULL )
return (1);
FDL_set_title( fdl, "EXP プログラムの環境設定");
FDL_set_wildcard( fdl, "*.exp");
ret = FDL_start(fdl);
if ( ret == NORMAL )
strcpy( fn, FDL_get_filename(fdl));
FDL_close(fdl);
if ( ret != NORMAL || strlen(fn) == 0 )
return (1);
if ( (fp = FM_fopen(fn,"rb")) == NULL )
{
DLG_tmpMsgTime( DLGPOS_MOS_SET_CENTER, DLGPOS_MOS_SET_CENTER,
C_MBLACK, C_DLGBASE, COLMIX(C_ERROR,C_GRAY),
AplErrMsgTime, " %s : \n FILE OPEN ERROR!! ", fn );
return (1);
}
dlg = DLG_msgOpen( DLGPOS_CENTER_OF_SCN, DLGPOS_CENTER_OF_SCN,
6*48,12*14, C_MBLACK, C_DLGBASE, COLMIX(C_INFO,C_GRAY),
"EXP HEADER INFORMATION");
if ( dlg == NULL )
return (ERR);
DLG_msgSetConfig( dlg, 4, 6, 12 );
DLG_msgClear( dlg, C_HWHITE );
DLG_msgPrintf(dlg,"FILE : %s\r\n", fn );
DLG_msgPrintf(dlg,"\tcheck header" );
fseek( fp, 0, SEEK_SET);
fread( buf, 2, 1, fp );
if ( buf[0] != 'P' || buf[1] != '3' )
{
DLG_tmpMsgTime( DLGPOS_MOS_SET_CENTER, DLGPOS_MOS_SET_CENTER,
C_MBLACK, C_DLGBASE, COLMIX(C_ERROR,C_GRAY),
AplErrMsgTime, " %s : \n P3形式のプログラムではありません。 ", fn );
DLG_msgClose(dlg);
return (1);
}
DLG_msgPrintf(dlg,"\tOk!!\r\n" );
/* チェックサム読み取り */
fseek(fp,0x0A,SEEK_SET);
fread( &chk_sum, 2, 1, fp );
DLG_msgPrintf(dlg,"\tcheck sum\t\t$%04X\r\n", chk_sum & 0xFFFF );
/* DX部オフセット読み取り */
fseek( fp, 0x0C, SEEK_SET);
fread( &dx_ofs, 4, 1, fp );
DLG_msgPrintf(dlg,"\tDX part offset\t$%08X\r\n", dx_ofs );
/* -maxibuf */
ofs = dx_ofs + 0x08;
fseek(fp,ofs,SEEK_SET);
fread( &maxibuf, 2, 1, fp );
DLG_msgPrintf(dlg,"\t-maxibuf\t%d\r\n", maxibuf );
/* -nistack */
ofs = dx_ofs + 0x0A;
fseek(fp,ofs,SEEK_SET);
fread( &nistack, 2, 1, fp );
DLG_msgPrintf(dlg,"\t-nistack\t%d\r\n", nistack );
/* -istksize */
ofs = dx_ofs + 0x0C;
fseek(fp,ofs,SEEK_SET);
fread( &istksize, 2, 1, fp );
DLG_msgPrintf(dlg,"\t-istksize\t%d\r\n", istksize );
FM_fclose(fp);
DLG_msgPrintf(dlg,"file close\r\n" );
old_maxibuf = maxibuf ;
old_nistack = nistack ;
old_istksize = istksize;
obj = MNU_alloc( 11 );
_expSetup_sub( obj, maxibuf, nistack, istksize );
mnu = MNU_open( DLGPOS_MOS_SET_HOME, DLGPOS_MOS_SET_HOME, MNUATT_EXIT, obj, "設定" );
while ( 1 )
{ ret = MNU_start ( mnu );
if ( ret < 0 || ret == 9 )
break;
switch ( ret )
{ case 1: maxibuf = _expSetup_maxibuf ( maxibuf ); break;
case 2: nistack = _expSetup_nistack ( nistack ); break;
case 3: istksize = _expSetup_istksize( istksize ); break;
case 4: maxibuf = 64; nistack = 4; istksize = 2; break;
case 5: maxibuf = 64; nistack = 6; istksize = 2; break;
case 6: maxibuf = 64; nistack = 7; istksize = 2; break;
case 7: maxibuf = 64; nistack = 8; istksize = 2; break;
case 8: maxibuf = 64; nistack = 8; istksize = 4; break;
}
_expSetup_sub( obj, maxibuf, nistack, istksize );
}
MNU_close(mnu);
MNU_free(obj);
if ( ret < 0 )
{ DLG_msgClose(dlg);
return (1);
}
DLG_msgPrintf(dlg,"\r\n" );
DLG_msgPrintf(dlg,"\tNew -maxibuf \t%d\tOld %d\r\n" , maxibuf , old_maxibuf );
DLG_msgPrintf(dlg,"\tNew -nistack \t%d\tOld %d\r\n" , nistack , old_nistack );
DLG_msgPrintf(dlg,"\tNew -istksize\t%d\tOld %d\r\n" , istksize, old_istksize );
sum = chk_sum;
sum = (sum + (maxibuf - old_maxibuf )) & 0xFFFF;
sum = (sum + (nistack - old_nistack )) & 0xFFFF;
sum = (sum + (istksize - old_istksize)) & 0xFFFF;
DLG_msgPrintf(dlg,"\tNew check sum\t%$%04X\tOld $%04X\r\n", sum, chk_sum );
ret = MNU_sure ( DLGPOS_CENTER_OF_SCN, DLGPOS_CENTER_OF_SCN,
C_MBLACK, C_DLGBASE, COLMIX(C_INFO,C_GRAY), SELBTN_ATT_LEFT,
" この設定に変更します。 " );
if ( ret != MENU_SURE_OK )
{ DLG_msgClose(dlg);
return (ERR);
}
if ( (fp = FM_fopen(fn,"r+b")) == NULL )
{
DLG_tmpMsgTime( DLGPOS_MOS_SET_CENTER, DLGPOS_MOS_SET_CENTER,
C_MBLACK, C_DLGBASE, COLMIX(C_ERROR,C_GRAY),
AplErrMsgTime, " %s : \n FILE OPEN ERROR!! ", fn );
DLG_msgClose(dlg);
return (1);
}
/* -maxibuf */
ofs = dx_ofs + 0x08;
fseek(fp,ofs,SEEK_SET);
fwrite( &maxibuf, 2, 1, fp );
/* -nistack */
ofs = dx_ofs + 0x0A;
fseek(fp,ofs,SEEK_SET);
fwrite( &nistack, 2, 1, fp );
/* -istksize */
ofs = dx_ofs + 0x0C;
fseek(fp,ofs,SEEK_SET);
fwrite( &istksize, 2, 1, fp );
/* チェックサム */
ofs = 0x0A;
fseek(fp,ofs,SEEK_SET);
fwrite( &sum, 2, 1, fp );
FM_fclose(fp);
DLG_msgPrintf(dlg,"\r\n***** Completed *****\r" );
DLG_tmpMsgTime( DLGPOS_CENTER_OF_SCN, DLGPOS_CENTER_OF_SCN,
C_MBLACK, C_DLGBASE, COLMIX(C_TIMEBOX,C_GRAY),
4, " %s : \n プログラムを書き換えました。 \n 再起動してください。 ", fn );
DLG_msgClose(dlg);
return (0);
}